import java.time.Duration;
import java.time.LocalDateTime;

public class DurationTest {
    public static void main(String[] args) {
        // 计算两个时间相差的天 时 分 秒 毫秒  纳秒
        // 得到Duration对象
        LocalDateTime start = LocalDateTime.of(2099, 9, 9, 9, 9, 9);
        LocalDateTime end = LocalDateTime.of(2099, 9, 9, 10, 10, 10);

        Duration between = Duration.between(start, end);
        System.out.println(between.toDays());    // 间隔多少天
        System.out.println(between.toHours());   // 间隔多少小时
        System.out.println(between.toMinutes()); // 间隔多少分
        System.out.println(between.getSeconds()); // 间隔多少秒
    }
}
